<?php

namespace Cblood\Container\Annotation;


use Cblood\Container\Label\InjectionParameterLabel;

class Annotation
{
    /**
     * 有默认标签 Inject
     * 格式 array('label' => 'Cblood\HelloLabel')
     * @var array
     */
    protected static $collection = array('Inject' => InjectionParameterLabel::class);

    /**
     * 注册一个注释标签,供以后使用
     * @param array $annotationClass
     */
    public static function register($annotationClass = [])
    {
        static::$collection = array_merge(static::$collection, $annotationClass);
    }

    public static function get($name)
    {
        if (static::has($name)) {
            return static::$collection[$name];
        }

        throw new \Exception('该标签没有被注册：' . $name);
    }

    public static function all()
    {
        return static::$collection;
    }

    public static function has($name)
    {
        return isset(static::$collection[$name]);
    }
}